<?php 
	echo $this->element('menu'); 
	$currentUserInfo = $this->Session->read('Auth');
	$userId = $currentUserInfo['User']['id'];
?>

<div class="container">
	<div class="row">
		<div class="account_display_extensions">
              		<a href="/pinterest/Users/view/<?php echo $images[0]['Profile']['user_id'];?>">
	            	<?php
	            		echo $this->Html->image($images[0]['Profile']['avatar'],array(
	            													'alt'=>'CakePHP',
	            													'class'=>'img_display_extensions',
	            													'width'=>'100%',
	            													'height'=>'100%'));
	            	?>
	            	</a>
              		<p><?php echo $images[0]['Profile']['name']; ?></p>
            	</div>  
		<i><b><p><?php echo $board['Board']['name']; ?></p></b><i>

	</div>
	<div class="row">
	<?php 
  	if($images)
   		foreach($images as $image){ 
  	?>
		<div class="col-md-3">
        	<div class="display_extensions">
        		<a href="/pinterest/UserComments/comments/<?php echo $image['UserImageBoard']['id']; ?>">
            	<?php
            		echo $this->Html->image($image['Image']['url'],array(
            													'alt'=>'CakePHP',
            													'class'=>'img_display_extensions',
            													'width'=>'100%',
            													'height'=>'100%'));
            	?>
            	</a>
				
            	<div class="icon_display_extensions">
              		<div class="left_icon_display_extensions">
              		<?php
              			if($userId == $image['UserImageBoard']['user_id']){
              		?>
              			<a href="/pinterest/Boards/deleteImageInBoard/<?php echo $image['UserImageBoard']['id']; ?>/<?php echo $image['UserImageBoard']['board_id']; ?>">
	                		<button type="button" class="btn btn-default btn-xs">
	                  			<span class="glyphicon glyphicon-pushpin">
	                  				unPin
	                  			</span>
	                		</button>
                		</a>
                	<?php
                		}else{
                	?>
                		<a href="/pinterest/Boards/pinImageIntoBoard/<?php echo $image['UserImageBoard']['id']; ?>/<?php echo $image['UserImageBoard']['board_id']; ?>">
	                		<button type="button" class="btn btn-default btn-xs">
	                  			<span class="glyphicon glyphicon-pushpin">
	                  				Pin
	                  			</span>
	                		</button>
                		</a>
                	<?php
                		}
                	?>
              		</div>
              		<div class="right_icon_display_extensions">
              		<?php
              			if($image['UserLike']){
              		?>
		                <a href="/pinterest/UserLikes/unlikeImage/<?php echo $image['UserImageBoard']['id']; ?>">
			                <button type="button" class="btn btn-default btn-xs">
			                  <span class="glyphicon glyphicon-heart">
			                  	unLike
			                  </span>
			                </button>
		                </a>
		            <?php
                		}else{
                	?>
						        <a href="/pinterest/UserLikes/likeImage/<?php echo $image['UserImageBoard']['id']; ?>">
			                <button type="button" class="btn btn-default btn-xs">
			                  <span class="glyphicon glyphicon-heart">
			                  	Like
			                  </span>
			                </button>
		                </a>
                	<?php
                		}
                	?>
              		</div>
            	</div>
            	<p class="description_display_extensions row">
                <?php echo $image['UserImageBoard']['description']; ?>
              </p>
              <div class="description_display_extensions row">
                <div class="dropdown col-md-4">
                  <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
                    <span class="glyphicon glyphicon-heart">
                      <?php echo $image['UserImageBoard']['count_like']; ?>
                    </span>
                  </button>
                  <?php
                    if($image['UserImageBoard']['count_like'] > 0){
                  ?>
                  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                    <?php
                      foreach($image['ProfileLike'] as $profile){
                    ?>
                    <li role="presentation">
                      <a role="menuitem" tabindex="-1" href="/pinterest/Users/view/<?php echo $profile['Profile']['user_id'];?>">
                        <?php
                          echo $profile['Profile']['name'];
                        ?>
                      </a>
                    </li>
                    <?php
                      }
                    ?>
                  </ul>
                  <?php
                    }
                  ?>
                </div>
                            
                <span class="glyphicon glyphicon-sort col-md-4">
                  <?php echo $image['UserImageBoard']['count_pin']; ?>
                </span>

                <div class="dropdown col-md-4">
                  <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
                    <span class="glyphicon glyphicon-comment">
                      <?php echo $image['UserComment']; ?>
                    </span>
                  </button>
                  <?php
                    if($image['UserComment'] > 0){
                  ?>
                  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                    <?php
                      foreach($image['ProfileComment'] as $profile){
                    ?>
                    <li role="presentation">
                      <a role="menuitem" tabindex="-1" href="/pinterest/Users/view/<?php echo $profile['Profile']['user_id'];?>">
                        <?php
                          echo $profile['Profile']['name'];
                        ?>
                      </a>
                    </li>
                    <?php
                      }
                    ?>
                  </ul>
                  <?php
                    }
                  ?>
                </div>
              </div>   
          	</div>
        </div>
        <?php } ?>
    </div>
</div>